library(kknn)
library(caret)

setwd("D:/ClassificationR")

#membaca data training & data testing
data.training = read.csv("iris2class.train.1.csv")
data.test = read.csv("iris2class.test.1.csv")

#membuat model & melakukan prediksi 
model = kknn(Species~., data.training, data.test[,-5], k = 5, distance = 1, kernel = "triangular")

#menghitung kinerja
performance.value = confusionMatrix(model$fitted.values, data.test[,5])
print(performance.value)
